# 导包
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep, strftime

driver = webdriver.Firefox()
driver.maximize_window()
url = 'https://www.baidu.com'
driver.get(url)

# 设置cookie
driver.add_cookie({
    'name': 'BDUSS',
    'value': 'mo3Yk1sSXhtTnE5dWRFNHRZaGktUE5PaTFNeXZFT0dtMVlxRXVpbGZRN0NqWGRuRVFBQUFBJCQAAAAAAAAAAAEAAACHQjM~a2FybLPJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMIAUGfCAFBnS'
})
# 必须刷新
sleep(3)
driver.refresh()
# 获取cookies
# 所有的
cookies = driver.get_cookies()
# print(cookies)
for item in cookies:
    print(item['name'])
# 获取具体某一个
print(driver.get_cookie('PSTM'))

sleep(3)
driver.quit()